/**
 * COOKIE存储
 * @param {String} key 键
 * @param {Object} data 值
 * @param {Number} time 时间，默认1s
 */

function  setcookie(key,data,time = 1)
{
    if(typeof data == "object")  data = JSON.stringify(data)
    const dtime = new Date
    dtime.setTime(dtime.getTime() - 1000*60*60*8 + 1000*time)
    document.cookie = `${key}=${data};expires=${dtime}`
}


function  getcookie(key)
{
    let arr = document.cookie.split("; ")
    for(let i=0;i<arr.length;i++)
    {
        let arrc = arr[i].split("=")
        if(arrc[0] == key) return arrc[1]
    }
}


function  removecookie(key)
{
    setcookie(key,null,-1)
}